﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Nhibernate.GuitarStore.DataAccess;
using Nhibernate.GuitarStore.Common;

namespace GuitarStore
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            NHibernateBase nhb = new NHibernateBase();
            nhb.Initialize("Nhibernate.GuitarStore");
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            NHibernateInventory nhi = new NHibernateInventory();
            List<Inventory> list = (List<Inventory>)nhi.ExecuteICriteriaOrderBy("Builder");
            dataGrid1.ItemsSource = list;
            PopulateComboBox();
        }

        private void PopulateComboBox()
        {
            NHibernateBase nhb = new NHibernateBase();
            IList<Guitar> guitarTypes = nhb.ExecuteICriteria<Guitar>();
            cboGuitarTypes.ItemsSource = guitarTypes;
            //foreach (var item in guitarTypes)
            //{
            //    cboGuitarTypes.Items.Add(item);
            //}

            cboGuitarTypes.SelectedValuePath = "Id";
            cboGuitarTypes.DisplayMemberPath = "Type";
        }
    }
}
